<template>
  <div>
    <div>
      <table>
        <thead>
          <tr>
            <th v-for="item in col" :key="item.key">{{item.title}}</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(row,index) in data" :key="index">
            <td v-for="item in col" :key="item.key">{{row[item.key]}}</td>
          </tr>
        </tbody>
          
      </table>
    </div>  
  </div>
</template>
<style scoped>
.expand-row {
  margin-bottom: 16px;
}
.modal img {
  width: 100%;
}
</style>
<script>
export default {
  props: {
    row: Array
  },
  mounted() {
    this.row[0].registerinfos.forEach(row => {
      this.col.push({
        title: row.show_name,
        key: row.key_name
      });
    });

    this.col.push({
      title:"状态",
      key:'statename'
    })

    this.row.forEach(item => {
      let obj = {};
      item.registerinfos.forEach(row => {
        obj[row.key_name] = row.value;
      });

      obj.statename = item.state==1?'已提交':'未提交'

      this.data.push(obj);
    });
  },
  methods: {
    show_img(data) {
      this.img_url = data.row[data.column.key];
      this.show = true;
    }
  },
  data() {
    return {
      col: [],
      data: [],
      show: false,
      img_url: ""
    };
  }
};
</script>
<style scoped>
  table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #dcdee2;
  }
  thead tr{

  }

  thead th {
    width: 10%;
    height: 40px;
    white-space: nowrap;
    overflow: hidden;
    background-color: #f8f8f9;
  }

  /*thead th:nth-child(2) {
    width: 20%;
  }*/

  thead th:nth-child(3) {
    width: 15%;
  }

  /*thead th:nth-child(4) {
    width: 35%;
  }*/
  tbody td {
    min-width: 0;
    height: 48px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    text-align: left;
    text-overflow: ellipsis;
    vertical-align: middle;
    border-bottom: 1px solid #e8eaec;
    background-color: #ffffff;

  }

  th, td {
    padding: 5px;
    color: #515a6e;
    font-size: 12px;
  }

  td {
    letter-spacing: 1px;
    text-align: center;
  }
</style>
